<template>
  <view class="content">
    <!-- 2.0.19支持autoBack，默认为false -->
    <u-navbar :placeholder='true' title="個人中心" leftIcon="arrow-leftward"
              @leftClick="leftClick('/pages/mine/index')">
    </u-navbar>
    <view class="table">
      <u-cell-group>
        <u-cell v-if="power.includes(0)" title="公司資料修改" isLink url="/pages/mine/setting/company/index"></u-cell>
        <u-cell v-if="power.includes(0) || power.includes(4) || power.includes(111)" title="用戶密碼修改" isLink
                url="/pages/mine/setting/pwd/index"></u-cell>
      </u-cell-group>
    </view>
    <view class="table"
          v-if="power.includes(0) || power.includes(3) ||power.includes(1)||power.includes(2)||power.includes(5)">
      <u-cell-group>
        <u-cell v-if="power.includes(0) || power.includes(3) || power.includes(111)" title="收貨地址管理" isLink
                url="/pages/mine/setting/address/index"></u-cell>
        <u-cell v-if="power.includes(0) || power.includes(1)" title="管理分行/子公司" isLink
                url="/pages/mine/setting/childcompany/index"></u-cell>
        <u-cell v-if="power.includes(0) || power.includes(2)" title="管理部門" isLink
                url="/pages/mine/setting/branch/index"></u-cell>
        <u-cell v-if="power.includes(0) || power.includes(5)" title="管理用戶" isLink
                url="/pages/mine/setting/person/index"></u-cell>
      </u-cell-group>
    </view>
    <view class="table">
      <u-cell-group>
        <!--				<u-cell title="隱私政策" isLink url="/pages/mine/setting/privacy/index"></u-cell>-->
        <u-cell title="關於新極速" isLink url="/pages/mine/setting/about/index"></u-cell>
      </u-cell-group>
    </view>
    <view class="table btn" @click="logout">
      退出登錄
    </view>

  </view>
</template>

<script>
import {
  mapState,
  mapGetters,
  mapMutations,
  mapActions
} from 'vuex'
// import {getPowers} from "@/network/api/user";

export default {
  data() {
    return {
      // power: []

    }
  },
  computed: {
    ...mapState({
      power: state => state.user.power
    })
  },
  onLoad() {
    // this.getPower()
  },
  onShow() {
    // this.getPower()
  },
  methods: {
    // async getPower() {
    //   const res = await getPowers();
    //   this.power = res.data.power
    // },
    ...mapActions(['logout']),
    leftClick(url) {
      console.log('rightClick');
      uni.switchTab({
        url: url
      })
    },
  }
}
</script>

<style lang="scss">
.content {
  width: 100%;
  height: 100vh;
  background-color: #F5F6F9;

  .table {
    background-color: white;
    margin: 16rpx 0;
  }

  .btn {
    text-align: center;
    font-size: 32rpx;
    font-family: PingFang SC;
    font-weight: 500;
    color: #333333;
    padding: 32rpx 0;
  }
}
</style>
